const mysql = require("mysql");
const pool = mysql.createPool({
    host:"localhost",
    port:3306,
    user:"root",
    password:"root",
    database:"db-system"
})
async function dbquery(sqlStr,queryCharacter){
    let result = await new Promise((resolve,reject) => {
        pool.query(sqlStr,
            queryCharacter,
            (err,result) => {
            if (err){
                console.log(err);
                reject(err);
            }
            else{
                resolve(result);
            }
        })

    })
    return result;
}

module.exports = {
    dbquery
}